package com.server.pojo.base;

import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.*;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

import javax.persistence.*;
import java.util.Date;

@EntityListeners(AuditingEntityListener.class)
@JsonIgnoreProperties({"hibernateLazyInitializer"}) // hibernateLazyInitializer 会导致报错故此忽略
@MappedSuperclass
@EnableJpaAuditing
@Getter
@Setter
@ToString
@Accessors(chain = true)

@SuperBuilder
@NoArgsConstructor
public class PojoBase {

    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Id
    protected Integer id;


    @CreatedDate
    @Temporal(TemporalType.TIMESTAMP)
    @JSONField(format = "millis")
    protected Date createdAt;

}
